var a = getApp(), t = require("../../utils/util.js");

Page({
    data: {
        list: a.globalData.xzwdata,
        hei: a.globalData.sheight,
        infodata: null,
        modalHidden: !1,
        showModalStatus: !1,
        mengshow: !1,
        bottom: "-100%",
        sharelayer: !1,
        sharebox: !1,
        sharemodal: !1,
        bot: "-100%",
        openSettingBtnHidden: !0,
        hide_qcode: 1,
        id: 1,
        name: "白羊座",
        currentTab: 0,
        tab: [ "今日", "明日", "本周", "本月", "今年", "爱情" ],
        userInfo: "",
        hasUserInfo: !1,
        canIUse: wx.canIUse("button.open-type.getUserInfo"),
        show: !0,
        date: [],
        showTabs: !1
    },
    onLoad: function(e) {
        var o = this, s = this, n = s.options.id || s.data.id;
        if (isNaN(n)) {
            n = n.toLowerCase();
            for (var r = 0; r < s.data.list.length; r++) n == s.data.list[r].en.toLowerCase() && (n = r + 1);
        }
        var i = decodeURIComponent(this.options.scene);
        if (i) {
            var d = a._get(i, "id");
            d && (n = d), s.setData({
                id: n
            });
        }
        t.getData(n, s, "xz", function() {
            encodeURIComponent("id=" + n);
        }), a.globalData.userInfo ? this.setData({
            userInfo: a.globalData.userInfo,
            hasUserInfo: !0
        }) : this.data.canIUse ? a.userInfoReadyCallback = function(a) {
            o.setData({
                userInfo: a.userInfo,
                hasUserInfo: !0
            });
        } : wx.getUserInfo({
            success: function(t) {
                a.globalData.userInfo = t.userInfo, o.setData({
                    userInfo: t.userInfo,
                    hasUserInfo: !0
                });
            }
        }), s.data.infodata && drawImg.downImg(img_user, "user_" + s.data.userInfo.nickName);
    },
    swichNav: function(a) {
        var t = this, e = a.target.dataset.current;
        if (e || (e = a.detail.current + 1), t.data.currentTab === e - 1) return !1;
        t.setData({
            currentTab: e - 1,
            showTabs: !1
        });
    },
    changexz: function(a) {
        var e = this, o = a.currentTarget.dataset.index;
        if (o === e.data.id) return t.hideModal(e), !1;
        t.getData(o, e, "xz", function() {
            var a = "https://api.xzw.com/static/image/xcx/xz_" + o + ".png";
            drawImg.downImg(a, "xzimg_" + o);
            var t = "https://api.xzw.com/cp/wxcode?sid=2&hyaline=1&color=5566e4&scene=" + encodeURIComponent("id=" + o);
            drawImg.downImg(t, "qcode_" + o);
        }), t.hideModal(e, "showModalStatus", "mengshow", "bottom");
    },
    showModal: function() {
        var a = this;
        t.showModal(a, "modalHidden", "showModalStatus", "mengshow", "bottom");
    },
    hideModal: function() {
        var a = this;
        t.hideModal(a, "showModalStatus", "mengshow", "bottom");
    },
    showShareModal: function() {
        var a = this;
        a.setData({
            showTabs: !1
        }), t.showModal(a, "sharebox", "sharemodal", "sharelayer", "bot");
    },
    hideShareModal: function() {
        var a = this;
        t.hideModal(a, "sharemodal", "sharelayer", "bot");
    },
    getUserInfo: function(t) {
        console.log(t), a.globalData.userInfo = t.detail.userInfo, this.setData({
            userInfo: t.detail.userInfo,
            hasUserInfo: !0
        }), drawImg.downImg(t.detail.userInfo.avatarUrl, "user_" + t.detail.userInfo.nickName), 
        drawImg.setData({
            userInfo: t.detail.userInfo
        });
    },
    share: function() {
        var a = this;
        t.hideModal(a, "sharemodal", "sharelayer", "bot"), drawImg.setData({
            xzimg: wx.getStorageSync("xzimg_" + a.data.id),
            img_user: wx.getStorageSync("user_" + a.data.userInfo.nickName),
            qcode: wx.getStorageSync("qcode_" + a.data.id),
            userInfo: a.data.userInfo,
            desc: a.data.infodata[a.data.currentTab],
            currentTab: a.data.currentTab,
            xzname: a.data.name,
            date: a.data.date
        }), a.setData({
            hide_qcode: 0
        }), drawImg.draw(a);
    },
    closeQcode: function() {
        this.setData({
            hide_qcode: 1
        });
    },
    handleSetting: function(a) {
        var t = this;
        a.detail.authSetting["scope.writePhotosAlbum"] && (t.setData({
            openSettingBtnHidden: !0
        }), drawImg.save_file(t));
    },
    inbtn: function(a) {
        console.log("in");
    },
    onShareAppMessage: function(a) {
        return "button" === a.from && console.log(a.target), {
            title: "星座运势详情",
            path: "/pages/fortune_astro/fortune_info?id=" + this.data.id,
            success: function(a) {},
            fail: function(a) {}
        };
    },
    showTabs: function() {
        var a = !this.data.showTabs;
        this.setData({
            showTabs: a
        });
    },
    hideTabs: function() {
        this.setData({
            showTabs: !1
        });
    }
});